<%@ page  contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="page" uri="http://www.forten.org/taglib/page"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>已选课程</title>
<!-- CSS -->
<link type="text/css" rel="stylesheet" href="../styles/css/reset.css">
<link type="text/css" rel="stylesheet" href="../styles/css/index.css">
<link type="text/css" rel="stylesheet" href="../styles/css/button.css">
<script type="text/javascript" src="../scripts/html5.js"></script>
<!-- end -->
<!-- fancybox -->
<style type="text/css">
.textarea {
	color: gray;
}
</style>
<script>
	!window.jQuery
			&& document
					.write('<script src="../scripts/jquery-1.6.min.js"><\/script>');
</script>
<script type="text/javascript"
	src="../scripts/fancybox/jquery.fancybox-1.3.4.pack.js" charset="utf-8"></script>
<link media="screen" type="text/css" rel="stylesheet"
	href="../scripts/fancybox/jquery.fancybox-1.3.4.css">
<!-- end -->
<!-- 日期控件 -->
<script type="text/javascript" src="../scripts/Calendar/Js/calendar.js"></script>
<link type="text/css" rel="stylesheet"
	href="../scripts/Calendar/Css/calendar.css" />
<!-- end -->
</head>
<style type="text/css">
.textarea {
	color: gray;
}
</style>
<body>
	<script type="text/javascript">
	 function doSubmitCancelReason(frmId){
		 var formData = $('#'+frmId).serialize();
		 $.ajax({
				type:'post',
				data:formData,
				url:'../selectcourse/cancelCourse.jspx',
				success:function(data){
					window.location.reload();
				}
			});
	   }
	 
	 function doSubmitLeaveReason(frmId){
		 var formData = $('#'+frmId).serialize();
		 $.ajax({
				type:'post',
				data:formData,
				url:'../selectcourse/leaveQuick.jspx.jspx',
				success:function(data){
					window.location.reload();
				}
			});
	  }
	
		function doQuery() {
			var start = $('#start');
			var end = $('#end');
			if(start.val() == '' && end.val() !=''){
				alert('请选择您要查询上课时间的起始时间！');
			}
			document.frm1.action = "showCourseSelectByAdminList.jspx";
			document.frm1.submit();
		}
		$(document).ready(function() {
			<c:forEach items="${dto}" var="dto" varStatus="s">
			$("#cancelCourse${s.index }").fancybox({
				'titlePosition' : 'inside',
				'transitionIn' : 'none',
				'transitionOut' : 'none'
			});
			$("#leave${s.index }").fancybox({
				'titlePosition' : 'inside',
				'transitionIn' : 'none',
				'transitionOut' : 'none'
			});
			$("#state${s.index }").fancybox({
				'titlePosition' : 'inside',
				'transitionIn' : 'none',
				'transitionOut' : 'none'
			});
			$("#attend${s.index }").fancybox({
				'titlePosition' : 'inside',
				'transitionIn' : 'none',
				'transitionOut' : 'none'
			});
			$("#reasonInfo${s.index }").fancybox({
				'titlePosition' : 'inside',
				'transitionIn' : 'none',
				'transitionOut' : 'none'
			});
			
			   $("#leaveReason${s.index}").focus(function() {
			       if ($(this).val() == "请输入请假原因")
			           $(this).val("");
			       $(this).removeClass("textarea");
			   }).blur(function() {
			   if ($(this).val() == "") {
			           $(this).val("请输入请假原因"); $(this).addClass("textarea");
			       }
			   });
			   $("#absentReason${s.index}").focus(function() {
			       if ($(this).val() == "请输入缺勤原因")
			           $(this).val("");
			       $(this).removeClass("textarea");
			   }).blur(function() {
			   if ($(this).val() == "") {
			           $(this).val("请输入缺勤原因"); $(this).addClass("textarea");
			       }
			   });
			   
			   $("#cancelReason${s.index}").focus(function() {
			       if ($(this).val() == "请输入退课原因")
			           $(this).val("");
			       $(this).removeClass("textarea");
			   }).blur(function() {
			   if ($(this).val() == "") {
			           $(this).val("请输入退课原因"); $(this).addClass("textarea");
			       }
			   });
			   </c:forEach>
		});
	</script>
	<c:if test="${! empty message}">
		<script type="text/javascript" language="javascript">
		 window.onload =function(){
			 var message = "${message}";
			 alert(message);
		 }
		</script>
	</c:if>

	<header>
	<div class="headerWrap"></div>
	</header>

	<div class="content">

		<section>
		<div class="rc_fbt">
			<form:form id="frm1" name="frm1" modelAttribute="courseSelectionQo"
				action="showCourseSelectByAdminList.jspx">
				<span class="left"> 
					<span class="ml15 mr5 left">上课时间从</span>
					<form:input path="start" class="s_txt left mt13" 
					onclick="displayCalendar(this, 'yyyymmdd', this, false, '');"
										size="8" maxlength="8" readonly="true"/>
					<span class="ml15 mr5 left">至</span>
					<form:input path="end" class="s_txt left mt13" 
					onclick="displayCalendar(this, 'yyyymmdd', this, false, '');"
										size="8" maxlength="8" readonly="true"/>
					
					<span class="mlr15 left">课程名</span> <form:input path="courseName"
						class="s_txt ml5 left mt13" />
				<span class="ml15 mr5 left">工作证号</span> <form:input
						path="cardNum" class="s_txt left mt13" /> <span
					class="mlr15 left">姓名</span> <form:input path="cadreName"
						class="s_txt ml5 left mt13" /> 
				<a class="btn_search ml10 left mt10" href="#" onclick="doQuery();"></a>
				</span>
				<p class="right">
				<a class="btn2 mt10" href="export2003.jspx">
				<span>导出03excel</span>
				</a>
				<a class="btn2 mt10" href="export2007.jspx"> 
				<span>导出07excel</span>
				</a>
				</p>
			</form:form>
		</div>
		<div class="rc_info mt20">
			<h3>
				<span class="r_title_ico"></span> 选课信息
			</h3>
		</div>
		<table class="rc_tab01" cellspacing="0" cellpadding="0">
			<tbody>
				<tr>
					<th style="text-align: center;">课程号</th>
					<th style="text-align: center;">课程名</th>
					<th style="text-align: center;">干部姓名</th>
					<th style="text-align: center;">干部工作证号</th>
					<th style="text-align: center;">院系部处</th>
					<th style="text-align: center;">级别</th>
					<th style="text-align: center;">上课状态</th>
					<th style="text-align: center;">考勤短信</th>
					<th style="text-align: center;">操作</th>
				</tr>
				<c:forEach items="${dto}" var="dto" varStatus="s">
					<tr>
						<td style="text-align: center;">${dto.courseDto.num}</td>
						<td style="text-align: center;">${dto.courseDto.name}</td>
						<td style="text-align: center;">${dto.cadreDto.name}</td>
						<td style="text-align: center;">${dto.cadreDto.cardNum}</td>
						<td style="text-align: center;">${dto.cadreDto.unitName}</td>
						<c:if test="${dto.cadreDto.jobLevel =='1'}">
							<td style="text-align: center;">副部级</td>
						</c:if>
						<c:if test="${dto.cadreDto.jobLevel =='2'}">
							<td style="text-align: center;">正局级</td>
						</c:if>
						<c:if test="${dto.cadreDto.jobLevel =='3'}">
							<td style="text-align: center;">副局级</td>
						</c:if>
						<c:if test="${dto.cadreDto.jobLevel =='4'}">
							<td style="text-align: center;">正处级</td>
						</c:if>
						<c:if test="${dto.cadreDto.jobLevel =='5'}">
							<td style="text-align: center;">副处级</td>
						</c:if>
						<c:if test="${dto.cadreDto.jobLevel =='6'}">
							<td style="text-align: center;">正科级</td>
						</c:if>
						<c:if test="${dto.cadreDto.jobLevel =='7'}">
							<td style="text-align: center;">副科级</td>
						</c:if>
						
						<td style="text-align: center;" id="state_td">
						
						<c:if test="${dto.state =='0'}">
							出勤
						</c:if>
						
						<c:if test="${dto.state =='1'}">
							<a id="reasonInfo${s.index }" href="#inline0${s.index }"
							title="请假原因">请假</a>
						</c:if>
						
						<c:if test="${dto.state =='2'}">
							<a id="reasonInfo${s.index }" href="#inline0${s.index }"
							title="缺勤原因">缺勤</a>
						</c:if>
						
							<div style="display: none;">
								<div id="inline0${s.index }"
									style="width: 400px; height: 120px; overflow: auto; word-break: break-all;">
								<fieldset>${dto.stateExplanation }</fieldset>
								</div>
							</div>
						</td>
						
						<td style="text-align: center;">
						A/B
						</td>
						<td class="rc_cr" style="text-align: center;"><a
							id="cancelCourse${s.index }" href="#inline1${s.index }"
							title="退课原因">退课</a> &nbsp;|&nbsp; <a id="leave${s.index }"
							href="#inline2${s.index }" title="请假明细">请假</a> &nbsp;|&nbsp; <a
							id="state${s.index }" href="#inline3${s.index }" title="缺勤原因">缺勤</a>
							<c:if test="${dto.state !='0' }">
							 &nbsp;|&nbsp; <a id="attend${s.index }" href="#inline4${s.index }" title="修改为出勤状态">出勤</a>
							</c:if>

							<div style="display: none;">
								<div id="inline1${s.index }"
									style="width: 400px; height: 120px; overflow: auto; word-break: break-all;">
									<form action="cancelCourse.jspx" method="post" id="frm1${s.index }" name="frm1${s.index }"
										onsubmit="if(document.getElementById('cancelReason${s.index }').value =='请输入退课原因')document.getElementById('cancelReason${s.index }').value='';">
										<input type="hidden" value="${dto.id}" name="selectedCourseId"
											id="selectedCourseId" />
											<%-- <forten:token name="cancelCourse"></forten:token> --%>
										<textarea name="cancelReason" id="cancelReason${s.index }"
											class="textarea" rows="4" cols="30">请输入退课原因</textarea>
										<br>
										<div>
											<input type="button" value="确定" class="button" onclick="doSubmitCancelReason('frm1${s.index }');"/>
										</div>
									</form>
								</div>
							</div>
							
							<div style="display: none;">
								<div id="inline2${s.index }"
									style="width: 400px; height: 120px; overflow: auto; word-break: break-all;">
									<form action="leaveQuick.jspx" method="post" id="frm2${s.index }" name="frm2${s.index }"
										onsubmit="if(document.getElementById('leaveReason${s.index }').value =='请输入请假原因')document.getElementById('leaveReason${s.index }').value='';">
										<input type="hidden" value="${dto.id}" name="selectedCourseId"
											id="selectedCourseId" />
											<%-- <forten:token name="leaveQuick1"></forten:token> --%>
										<textarea rows="4" cols="30" name="leaveReason"
											id="leaveReason${s.index }" class="textarea">请输入请假原因</textarea>
										<input type="hidden" value="1" id="state" name="state">
										<br> <input type="button" value="确定" class="button" onclick="doSubmitLeaveReason('frm2${s.index }')"/>
									</form>
								</div>
							</div>

							<div style="display: none;">
								<div id="inline3${s.index }"
									style="width: 400px; height: 120px; overflow: auto; word-break: break-all;">
									<form action="leaveQuick.jspx" method="post" id="frm3${s.index }" name="frm3${s.index }"
										onsubmit="if(document.getElementById('absentReason${s.index }').value =='请输入缺勤原因')document.getElementById('absentReason${s.index }').value='';">
										<input type="hidden" value="${dto.id}" name="selectedCourseId"
											id="selectedCourseId" />
											<%-- <forten:token name="leaveQuick2"></forten:token> --%>
										<textarea rows="4" cols="30" name="leaveReason"
											id="absentReason${s.index }" class="textarea">请输入缺勤原因</textarea>
										<input type="hidden" id="state" name="state" value="2" />
										<br> <input type="button" value="确定" class="button" onclick="doSubmitLeaveReason('frm3${s.index }')"/>
									</form>
								</div>
							</div>

							<div style="display: none;">
								<div id="inline4${s.index }"
									style="width: 400px; height: 120px; overflow: auto; word-break: break-all;">
									<form action="leaveQuick.jspx" method="post" id="frm4${s.index }" name="frm4${s.index }">
										<input type="hidden" value="${dto.id}" name="selectedCourseId"
											id="selectedCourseId" />
											<%-- <forten:token name="leaveQuick3"></forten:token> --%>
										<input type="hidden" name="leaveReason" value="" />
										<textarea rows="4" cols="30" disabled="disabled">您正在修改此干部为出勤状态，如无特殊原因请不要执行此操作！</textarea>
										<input type="hidden" value="0" id="state" name="state">
										<br> <input type="button" value="确定" class="button" onclick="doSubmitLeaveReason('frm4${s.index }')"/>
									</form>
								</div>
							</div>
							
						</td>
					</tr>
				</c:forEach>

			</tbody>
		</table>
		<page:page hrefStr="showCourseSelectByAdminList.jspx" name="page"></page:page>

		</section>
	</div>

<%@include file="/common/foot.jsp"%>